#!/usr/bin/env pypy2
# coding: utf-8
#### license: creative commons cc0 1.0 (public domain) 
#### http://creativecommons.org/publicdomain/zero/1.0/ 
proginf = "diogenes 0.1, jun 2020 mn"

# plato once defined man as a "featherless biped".
# diogenes plucked a chicken for plato and said "behold a man!"

# is free culture as important as free software?
# rms considers programming languages separate and "practical"
# (they do stuff). for copyright eligibility, that point matters.

# this is a programming language which turns verbatim-copy-only
# essays by richard stallman into non-free software.

# $ cat saying-no-even-once.txt | diogenes.py > man.py
# compiles saying-no-even-once.txt to man.py

# % turn on/off printing
# @ quit program
# a, A cycle colour backwards
# b, B cycle colour
# c, C copy next variable value to following character variable
# d, D move down most recent variable value
# e, E toggle print default upper/lower (starts lower)
# f, F move to 1, 1
# g, G get next character variable value
# h, H append next variable value to following character variable
# i, I set next variable to empty string
# j, J fi
# k, K if most recent variable value is true, do the following
# l, L move left most recent variable value
# m, M convert most recent value to uppercase
# n, N convert most recent value to lowercase
# o, O set next variable to 0
# p, P print most recent variable value
# q, Q exit loop early (limited)
# r, R move right most recent variable value
# s, S turn off print default case
# t, T set next variable to random number 0 to 99
# u, U move up most recent variable value
# v, V set next letter to following character
# w, W loop most recent variable value times
# x, X mark end of loop
# y, Y wait next value seconds
# z, Z clear screen

funcs = """
vars = {}
locx = 10
locy = 10
locolour = 7
togprint = 0
lutog = 0
from random import randint
for each in "abcdefghijklmnopqrstuvwxyz":
    vars[each] = ""
import sys
from time import sleep
from sys import stdout
def colour(colour_f, colour_b): 
    if colour_f == None: colour_f = 0
    if colour_b == None: colour_b = 0
    colour_n = "0"
    if colour_f > 7:    colour_n = "1" ; colour_f = colour_f - 8
    if colour_f == 1:   colour_f = 4 ## switch ansi colours for dos cga
    elif colour_f == 4: colour_f = 1 ## 1 = blue not red, 4 = red not blue
    if colour_f == 3:   colour_f = 6
    elif colour_f == 6: colour_f = 3
    if colour_b > 7:    colour_b = colour_b - 8
    if colour_b == 1:   colour_b = 4
    elif colour_b == 4: colour_b = 1
    if colour_b == 3:   colour_b = 6
    elif colour_b == 6: colour_b = 3
    stdout.write("\x1b[" + colour_n + ";" + str(30+colour_f) + 
    ";" + str(40+colour_b) + "m")
    stdout.flush()
def xy(mx, my, loc): 
    stdout.write("\x1b["+str(my)+";"+str(mx)+"H")
    colour(0, loc)
    stdout.write(" ")
    colour(loc, 0)
def cls():
    esc = chr(27)
    stdout.write(esc + "[2J" + esc + "[1;1H")
    sys.stdout.flush()
def val(n): 
    try: 
        n = float(n) 
    except: 
        n = 0 
    if float(int(n)) == float(n): 
        n = int(n) 
    return n
def figure(p, vars, t):
    about = vars[p]
    if t == "n":
        if about in ("0", 0): 
            return 0
        if val(about) != 0: 
            return val(about)
        return len(about)
def app(p, s):
    if type(p) == str:
        return p + str(s)
    else:
        return p + val(s)
def lu(p, s):
    if s == -1: return str(p).lower()
    if s == 1: return str(p).upper()
    return str(p)
"""

print funcs
import sys
from sys import stdin
p = stdin.read()
indent = 0
mode = "n"
dloop = 0 
loopcount = 0
vars = {}
alph = "abcdefghijklmnopqrstuvwxyz"
for each in alph:
    vars[each] = ""
mrv = "a"
for etter in p:
    letter = etter.lower()
    if letter in "%@" + alph:
        if mode == "n":
            if letter == "%":
                d = chr(32) * 4 * indent 
                print d + "if togprint: togprint = 0" 
                print d + "else: togprint = 1" 
            if letter == "e":
                d = chr(32) * 4 * indent 
                print d + "if togprint == 0: togprint = -1" 
                print d + "else: togprint = togprint * -1" 
            elif letter == "s":
                print chr(32) * 4 * indent + "lutog = 0" 
            elif letter == "@":
                print chr(32) * 4 * indent + "quit()" 
            elif letter == "z":
                print chr(32) * 4 * indent + "cls()"
            elif letter == "y":
                mode = "y"
            elif letter == "t":
                mode = "t"
            elif letter == "o":
                mode = "o"
            elif letter == "i":
                mode = "i"
            elif letter == "g":
                mode = "g"
            elif letter == "j":
                dloop = 0
                if indent > 0:
                    indent -= 1
            elif letter == "x":
                dloop = 0
                if indent > 0:
                    indent -= 1
            elif letter == "k":
                d = chr(32) * 4 * indent 
                print d + "if vars['" + mrv + "']:" 
                indent += 1
                print chr(32) * 4 * indent + "d0 = 0"
            elif letter == "p":
                d = chr(32) * 4 * indent 
                print d + "if togprint: print lu(vars['" + mrv + "'], lutog)" 
            elif letter == "w":
                dloop = 1
                loopcount += 1
                d = chr(32) * 4 * indent + "for loop" + str(loopcount) 
                print d + " in range(figure('" + mrv + "', vars, 'n')):"
                indent += 1
                print chr(32) * 4 * indent + "sleep(0.0001)"
            elif letter == "q":
                if dloop > 0:
                    print chr(32) * 4 * indent + "break"
            elif letter == "u":
                if letter:
                    print chr(32) * 4 * indent + "xy(locx, locy, locolour)"
                    loopcount += 1
                    d = chr(32) * 4 * indent + "for loop" + str(loopcount) 
                    print d + " in range(figure('" + mrv + "', vars, 'n')):"
                    indent += 1
                    print chr(32) * 4 * indent + "if locy > 0: locy -= 1"
                    print chr(32) * 4 * indent + "xy(locx, locy, locolour)"
                    indent -= 1
            elif letter == "l":
                if letter:
                    print chr(32) * 4 * indent + "xy(locx, locy, locolour)"
                    loopcount += 1
                    d = chr(32) * 4 * indent + "for loop" + str(loopcount) 
                    print d + " in range(figure('" + mrv + "', vars, 'n')):"
                    indent += 1
                    print chr(32) * 4 * indent + "if locx > 0: locx -= 1"
                    print chr(32) * 4 * indent + "xy(locx, locy, locolour)"
                    indent -= 1
            elif letter == "r":
                if letter:
                    print chr(32) * 4 * indent + "xy(locx, locy, locolour)"
                    loopcount += 1
                    d = chr(32) * 4 * indent + "for loop" + str(loopcount) 
                    print d + " in range(figure('" + mrv + "', vars, 'n')):"
                    indent += 1
                    print chr(32) * 4 * indent + "locx += 1"
                    print chr(32) * 4 * indent + "xy(locx, locy, locolour)"
                    indent -= 1
            elif letter == "d":
                if letter:
                    print chr(32) * 4 * indent + "xy(locx, locy, locolour)"
                    loopcount += 1
                    d = chr(32) * 4 * indent + "for loop" + str(loopcount) 
                    print d + " in range(figure('" + mrv + "', vars, 'n')):"
                    indent += 1
                    print chr(32) * 4 * indent + "locy += 1"
                    print chr(32) * 4 * indent + "xy(locx, locy, locolour)"
                    indent -= 1
            elif letter == "m":
                d = chr(32) * 4 * indent 
                print d + "if type(vars['" + mrv + "']) == str:"
                d = chr(32) * 4 + d
                print d + "vars['" + mrv + "'] = vars['" + mrv + "'].upper()"
            elif letter == "n":
                d = chr(32) * 4 * indent 
                print d + "if type(vars['" + mrv + "']) == str:"
                d = chr(32) * 4 + d
                print d + "vars['" + mrv + "'] = vars['" + mrv + "'].lower()"
            elif letter == "f":
                d = chr(32) * 4 * indent 
                print d + """stdout.write("\x1b["+str(1)+";"+str(1)+"H")"""
                print d + "stdout.flush()"
            elif letter == "v":
                mode = "v"
            elif letter == "c":
                mode = "c"
            elif letter == "h":
                mode = "h"
            elif letter == "b":
                print chr(32) * 4 * indent + "locolour += 1"
                print chr(32) * 4 * indent + "if locolour > 7: locolour = 0"
                print chr(32) * 4 * indent + "colour(locolour, 0)"
            elif letter == "a":
                print chr(32) * 4 * indent + "locolour -= 1"
                print chr(32) * 4 * indent + "if locolour < 0: locolour = 7"
                print chr(32) * 4 * indent + "colour(locolour, 0)"
            else: print "# " + letter
        elif mode == "y":
            if letter in alph:
                d = chr(32) * 4 * indent
                print d + "sleep(figure('" + letter + "', vars, 'n'))"
                mode = "n" 
                mrv = letter
        elif mode == "t":
            if letter in alph:
                d = chr(32) * 4 * indent
                print d + "vars['" + mrv + "'] = randint(0, 99)"
                mode = "n" 
                mrv = letter
        elif mode == "o":
            if letter in alph:
                d = chr(32) * 4 * indent
                print d + "vars['" + mrv + "'] = 0"
                mode = "n" 
                mrv = letter
        elif mode == "i":
            if letter in alph:
                d = chr(32) * 4 * indent
                print d + "vars['" + mrv + "'] = ''"
                mode = "n" 
                mrv = letter
        elif mode == "g":
            if letter in alph:
                mode = "n" 
                mrv = letter
        elif mode == "v":
            if letter in alph:
                d = chr(32) * 4 * indent
                mode = "v2" 
                mrv = letter
        elif mode == "v2":
            if letter:
                d = chr(32) * 4 * indent
                print d + "vars['" + mrv + "'] = chr(" + str(ord(etter)) + ")"
                mode = "n" 
        elif mode == "c":
            if letter in alph:
                d = chr(32) * 4 * indent
                print d + "copythis = vars['" + letter + "']"
                mode = "c2" 
                mrv = letter
        elif mode == "c2":
            if letter:
                d = chr(32) * 4 * indent
                print d + "vars['" + letter + "'] = copythis"
                mode = "n" 
                mrv = letter
        elif mode == "h":
            if letter in alph:
                d = chr(32) * 4 * indent
                print d + "appthis = vars['" + letter + "']"
                mode = "h2" 
                mrv = letter
        elif mode == "h2":
            if letter:
                d = chr(32) * 4 * indent + "vars['" + letter + "'] = "
                print d + "app(vars['" + letter + "'], appthis)"
                mode = "n" 
                mrv = letter

print "colour(7, 0)"
